package cn.wanho.service.impl;

import cn.wanho.dao.CmsTextProgrammerMapper;
import cn.wanho.dto.CmsTextProgrammer;
import cn.wanho.service.CmsTextProgrammerService;
import cn.wanho.rvo.myeasyexcel.CmsTextProgrammerData;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class CmsTextProgrammerServiceImpl implements CmsTextProgrammerService {
    @Resource
    public CmsTextProgrammerMapper cmsTextProgrammerMapper;
    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void insert(List<CmsTextProgrammerData> cmsTextProgrammerData,Integer id) {
        for (CmsTextProgrammerData data : cmsTextProgrammerData) {
            CmsTextProgrammer cq = new CmsTextProgrammer();
            cq.setSort(data.getSort());
            cq.setContent(data.getContent());
            cq.setAnswer(data.getAnswer());
            cq.setValue(data.getValue());
            cmsTextProgrammerMapper.insert(cq);
            System.out.println("数据插入数据库成功！！"+cq);
            redisTemplate.opsForSet().add("wanhocms:paper:programmer:"+ id,cq);

        }

    }
}
